package cn.cumt.lkk.webapp.validator;

import cn.cumt.lkk.model.Link;
import cn.cumt.lkk.webapp.util.ValidationUtil;
import org.springframework.validation.*;

/**
 * Created by lkk on 2015/5/2.
 */
public class LinkValidator implements Validator {
    @Override
    public boolean supports(Class<?> aClass) {
        return aClass== Link.class;
    }

    @Override
    public void validate(Object o, Errors errors) {
        ValidationUtils.rejectIfEmpty(errors,"href","errors.required",new Object[]{"链接"});
        ValidationUtils.rejectIfEmpty(errors,"text","errors.required",new Object[]{"文本"});
    }
}
